<template>
<el-dialog :title="dialogObject.title" width="700px" :visible.sync="dialogObject.formVisible">

    <el-checkbox-group v-model="checkedCities" >
        <el-checkbox v-for="city in cities" :label="city.code" :key="city.code">{{city.label}}</el-checkbox>
    </el-checkbox-group>
    <div style="text-align:right;padding-top:10px;" slot="footer" class="dialog-footer">
            <el-button @click="dialogObject.formVisible = false">取 消</el-button>
            <el-button type="primary" @click="onSubmit">确 定</el-button>
    </div>
</el-dialog>
</template>
<script>
  var _this;
  export default {
    data() {
      return {
        dialogObject:{formVisible:false, title:'添加常用功能'}, 
        checkAll: false,
        checkedCities: ['ADD', 'EDIT', 'DEL'],
        cities: [
            {code:'ADD',label:'添加', position:2},
            {code:'EDIT', label:'编辑', position:3},
            {code:'DEL', label:'删除', position:3}],
        isIndeterminate: true,

      };
    },
    created() {
        _this = this;
    },
    methods: {
        show() {
            
            _this.dialogObject.formVisible = true;
        },
        onSubmit() {
            if(_this.checkedCities.length == 0 ) {
                this.$message.error('请勾选功能');
                return;
            }
            var selCities = [];
            for(var i=0;i<_this.checkedCities.length;i++) {
                for(var j=0;j<_this.cities.length;j++) {
                    if(_this.checkedCities[i] == _this.cities[j].code) {
                        selCities.push(_this.cities[j]);
                    }
                }
            }
            _this.myUtils.appRequest({
                url: '/java/sys/function/addCommonly',
                method:'post',
                data:{checkedCities:selCities, menuId:_this.currentNodeData.id},
                callback:function(data) {
                    _this.$message({
                        showClose: true,
                        message: data.message,
                        type: 'success'
                    });
                    _this.dialogObject.formVisible=false;
                    
                },
                catch: function(res) {
                    console.log(res);
                }
            }, _this);
        }

    },
    props:['currentNodeData']
  };
</script>